package com.heima.wemedia.controller.v1;
import com.heima.model.article.dtos.ArticleCommentDto;
import com.heima.model.comment.dtos.CommentConfigDto;
import com.heima.model.comment.dtos.RepayCommentDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.CommentManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/comment/manage")
public class CommentManageController {

    @Autowired
    private CommentManageService commentManageService;


    @PostMapping("/find_news_comments")
    public PageResponseResult findNewsComments(@RequestBody ArticleCommentDto dto){
        return commentManageService.findNewsComments(dto);
    }

    @PostMapping("/update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody CommentConfigDto dto){
        return commentManageService.updateCommentStatus(dto);
    }

    /**
     * @Description:     回复评论
     * @Date 2023/6/28 11:08
     * @Author  朱传洋
     */
    @PostMapping("comment_repay")
    public ResponseResult replyComment(@RequestBody RepayCommentDto dto){
        return commentManageService.replyComment(dto);
    }

    /**
     * @Description:     删除评论
     * @Date 2023/6/29 11:10
     * @Author  张先赋
     */
    @DeleteMapping("/del_comment/{commentId}")
    public ResponseResult delectOne(@PathVariable("commentId") String commentId){
        return commentManageService.delectOneComment(commentId);
    }

    /**
     * @Description:     删除评论回复
     * @Date 2023/6/29 11:10
     * @Author  张先赋
     */
    @DeleteMapping("/del_comment_repay/{commentRepayId}")
    public ResponseResult delectOneRepay(@PathVariable("commentRepayId") String commentRepayId){
        return commentManageService.delectOneCommentRepay(commentRepayId);
    }
}